#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int firstMissingPositive(vector<int>& nums) {
    set<int> cur;
    for (auto& e : nums)
    {
        cur.insert(e);
    }
    for (auto& e : cur)
    {
        static int a = 0;
        if (e >= 0 && e - a > 1)
            return a + 1;
        if (e >= 0)
        {
            a = e;
        }
    }
    return *(cur.end());
}
int main()
{
    vector<int> a = { 7, 8, 9, 11, 12 };
    firstMissingPositive(a);
}
